package com.syh.app.basic.service.utils;

import com.google.gson.Gson;
import com.syh.app.basic.service.base.WsCMD;
import com.syh.app.basic.service.impl.Response;
import com.syh.app.basic.service.pojo.BytesResponse;
import com.syh.app.basic.service.pojo.ResponsePacket;
import com.syh.app.basic.utils.Loog;

/**
 * 创建者：SYH
 * 时间：2020/4/14 15:08
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class WsDataManager {
    private static WsDataManager wsDataManager;
    private String TAG = "WsDataManager";
    private Gson mGson = new Gson();
    private final long REFRESH_SPOT_MARKET_INTERVAL = 500;//刷新币币行情时间间隔 单位毫秒
    private long mLastRefreshTime = 0l;

    private WsDataManager() {
    }

    public static WsDataManager getInstance() {
        if (wsDataManager == null) {
            wsDataManager = new WsDataManager();
        }
        return wsDataManager;
    }

    public void dealWsResponse(int type, Response message) {
        BytesResponse bytesResponse = (BytesResponse) message;
        ResponsePacket responsePacket = bytesResponse.getResponsePacket();
        if (responsePacket.getCode() == 200 || responsePacket.getCmd() == WsCMD.JSONLOGIN) {
            Loog.d(TAG, responsePacket.getCmd() + "--" + new String(responsePacket.getBody()));
        } else {
            Loog.e(TAG, new String(responsePacket.getBody()) + "----" + responsePacket.getCmd());
        }
    }

}
